package com.itheima.stock.controller;

import com.itheima.stock.common.domain.InnerMarketDomain;
import com.itheima.stock.pojo.SysUser;
import com.itheima.stock.service.UserService;
import com.itheima.stock.vo.LoginReqVo;
import com.itheima.stock.vo.LoginRespVo;
import com.itheima.stock.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
public class UserController {

    @Autowired
    UserService userService;

    //测试
    @GetMapping("/test")
    public String getTest(){
        return "test";
    }

    //查询所有用户,测试用
    @GetMapping("/test2")
    public R<List<SysUser>> getAllUser(){
        return userService.findAllUser();
    }

    //验证登录
    @PostMapping("/login")
    public R<LoginRespVo> login(@RequestBody LoginReqVo vo) {
        return userService.login(vo);
    }

    //验证码
    @GetMapping("/captcha")
    public R<Map> generateCaptcha() {
        return userService.generateCaptcha();
    }
}
